//  service/user.js
"use strict";
const Service = require("egg").Service;
class AdminService extends Service {
  // 获取管理员用户信息
  async getAdminInfo(params) {
    const { app } = this;
    try {
      const result = await app.mysql.get("admin", params);
      return result;
    } catch (error) {
      console.log(error);
      return null;
    }
  }
  // 通过用户名获取管理员信息
  async getAdminByName(username) {
    const { app, ctx } = this;
    try {
      const result = await app.mysql.select("admin", {
        where: { username: username },
      });
      return result;
    } catch (error) {
      console.log(error);
      return null;
    }
  }
  // 管理员用户注册
  async register(params) {
    const { app } = this;
    try {
      const result = await app.mysql.insert("admin", params);
      return result;
    } catch (error) {
      console.log(error);
      return null;
    }
  }
}
module.exports = AdminService;
